package com.baidu.utils;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

/**
 * 创作时间：2019/9/16 14:15
 * 作者：李增强
 */
public class JDBCUtils {
    String driver="com.mysql.jdbc.Driver";
    String url="jdbc:mysql://localhost:3306/20190923?useUnicode=true&amp;characterEncodings=utf8";
    String username="root";
    String password="root";
    public Connection getConn(){
        try {
            Class.forName(driver);
            Connection conn = DriverManager.getConnection(url, username, password);
            return conn;
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return null;
    }

    public void closeJDBC(Connection conn){
        if(conn!=null){
            try {
                conn.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
    }
}
